#include <stdio.h>

#define MAXN 15
#define MAX(a,b) ((a)>(b)?(a):(b))

int MAP[MAXN];
int N;
int cnt;

int check(int x, int y) {
    int i;
    int m = MAX(x-1, MAX(y-1, N-y));
    for (i=1; i<=m; i++) {
        if (i<=x-1 && MAP[i] == y) return 0;
        if (x-i>=1 && y-i>=1 && MAP[x-i] == y-i) return 0;
        if (x-i>=1 && y+i<=N && MAP[x-i] == y+i) return 0;
    }
    return 1;
}

void DFS(int r) {
    int i;

    if (r > N) {
        cnt++;
        return;
    }

    for (i=1; i<=N; i++) {
        if (check(r, i)) {
            MAP[r] = i;
            DFS(r+1);
        }
    }
}


int main()
{
    N=13;
    //scanf("%d", &N);
    DFS(1);
    printf("%d\n", cnt);
    return 0;
}
